package com.ruoyi.otc.service.impl;

import java.util.Arrays;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;//导包
import com.ruoyi.otc.mapper.TopicMapper;
import com.ruoyi.otc.domain.Topic;
import com.ruoyi.otc.service.ITopicService;
import com.ruoyi.common.core.text.Convert;

/**
 * 评测Service业务层处理
 *
 * @author gjp
 * @date 2023-10-24
 */
@Service
public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements ITopicService
{
    @Autowired
    private TopicMapper topicMapper;

    /**
     * 查询评测
     *
     * @param id 评测主键
     * @return 评测
     */
    @Override
    public Topic selectTopicById(Long id)
    {
        return topicMapper.selectById(id);
    }

    /**
     * 查询评测列表
     *
     * @param topic 评测
     * @return 评测
     */
    @Override
    public List<Topic> selectTopicList(Topic topic)
    {
        return topicMapper.selectList(new QueryWrapper<>(topic));
    }

    /**
     * 新增评测
     *
     * @param topic 评测
     * @return 结果
     */
    @Override
    public int insertTopic(Topic topic)
    {
                topic.setCreateTime(DateUtils.getNowDate());
            return topicMapper.insert(topic);
    }

    /**
     * 修改评测
     *
     * @param topic 评测
     * @return 结果
     */
    @Override
    public int updateTopic(Topic topic)
    {
                topic.setUpdateTime(DateUtils.getNowDate());
        return topicMapper.updateById(topic);
    }

    /**
     * 批量删除评测
     *
     * @param ids 需要删除的评测主键
     * @return 结果
     */
    @Override
    public int deleteTopicByIds(String ids)
    {
        return topicMapper.deleteBatchIds(Arrays.asList(Convert.toStrArray(ids)));
    }

    /**
     * 删除评测信息
     *
     * @param id 评测主键
     * @return 结果
     */
    @Override
    public int deleteTopicById(Long id)
    {
        return topicMapper.deleteById(id);
    }
}
